package com.yifeng.repo.controller.traffic.in;

import com.yifeng.repo.base.utils.common.BaseUtil;

/**
 * Created by daibing on 2021/12/4.
 */
public class TrafficInManager {
    private static volatile String workerClassName = "com.yifeng.repo.controller.traffic.in.processor.worker.impl.DefaultTrafficInWorker";
    private static volatile boolean switchOn = true;

    static {
        String trafficSwitchOn = BaseUtil.getEnvSettingIfPresent("traffic.switch.on", "traffic_switch_on");
        if (!isBlank(trafficSwitchOn)) {
            switchOn = Boolean.parseBoolean(trafficSwitchOn);
        }
    }

    public static boolean isSwitchOn() {
        return switchOn;
    }

    public static String getWorkerClassName() {
        return workerClassName;
    }

    public static void setWorkerClassName(String workerClassName) {
        TrafficInManager.workerClassName = workerClassName;
    }

    private static boolean isBlank(String s) {
        return s == null || s.trim().length() == 0;
    }

}
